<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
		<title>代码生成</title>
		[#include "/html/include/easyuicss.html" /]
		[#include "/html/include/easyuijs.html" /]
		<script type="text/javascript" src="${app }/static/js/common.utils.js"></script>
		<script type="text/javascript" src="${app }/static/download/jquery.fileDownload.js"></script>
	</head>
	<body class="easyui-layout" data-options="fit:true" style="overflow-y: hidden">
	<table id="dgtable" class="easyui-datagrid" title="数据表信息" style="width:100%;height:100%;">
		<thead>
		<tr>
			<th data-options="field:'table_name',width:180">表名称</th>
			<th data-options="field:'engine',width:100">engine</th>
			<th data-options="field:'table_comment',width:120">表描述</th>
			<th data-options="field:'create_time',width:100">创建时间</th>
			<th data-options="field:'operating',width:30,formatter:getBtn">操作</th>
		</tr>
		</thead>
	</table>
	<div id="tb">
		<span>数据表名称:</span>
		<input  class="easyui-textbox" id="tableName" name="tableName" />
		<a href="javascript:;" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true" onclick="showList();">查询</a>
	</div>
	</body>
    <script type="text/javascript">
		$(document).ready(function(){
			$('#dgtable').datagrid({
				url: '${app}/systools/generator/list.do',
				method: 'post',
				queryParams: {tableName: $('#tableName').val()},
				singleSelect: true,
                fitColumns: true,
                rownumbers: true,
				toolbar: '#tb',
				onLoadSuccess: onLoadSuccess,
				pagination: true,
				pageSize: 20,
				pageList: [10,20,30]
			});
		});
		function getBtn(value, row, index) {
			var btnStr = '<a href="javascript:;" class="easyui-linkbutton" onclick="generatorCode(\''+row.table_name+'\')">生成</a>&nbsp;';
			return btnStr;
		}
		function onLoadSuccess(data){
			$('.easyui-linkbutton').linkbutton();
            $('#dgtable').datagrid('fixRowHeight');
		}
		function showList(){
			$('#dgtable').datagrid('load', {
                tableName: $('#tableName').val()
			});
		}
		function generatorCode(tableName){
			parent.easyui.confirm('系统提醒', '您确定要生成代码吗？', function(r){
				if (r){
					//parent.layer.load(2);
                    $.fileDownload('${app}/systools/generator/generatorCode.do?tableName='+tableName, {
                        failCallback: function(responseHtml, url){
                            parent.layer.closeAll('loading');
                            parent.easyui.msgShow('系统提醒', '代码生成失败！', 3000, 250, 100);
                        }
                    });
				}
			});
		}
    </script>
</html>